home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / lib / rpm-3.0.6 / find-requires < prev    next >
Encoding:
Text File  |  2001-04-06  |  1.3 KB  |  40 lines

  1. #!/bin/sh
  2.  
  3. # note this works for both a.out and ELF executables
  4. # it also auto-generates requirment lines for shell scripts
  5.  
  6. ulimit -c 0
  7.  
  8. filelist=`sed "s/['\"]/\\\&/g"`
  9. exelist=`echo $filelist | xargs -r file | grep ":.*executable" | cut -d: -f1 `
  10. scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) " | cut -d: -f1 `
  11. liblist=`echo $filelist | xargs -r file | grep ":.*shared object" | cut -d : -f1 `
  12.  
  13. exelist=`for f in $exelist; do [ -x $f ]&&echo $f; done`
  14. scriptlist=`for f in $scriptlist; do [ -x $f ]&&echo $f; done`
  15.  
  16. for f in $exelist; do
  17.     ldd $f | awk '/=>/ { print $1 }'
  18. done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
  19.  
  20. for f in $liblist; do
  21.     ldd $f | awk '/=>/ { print $1 }'
  22. done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | sort -u
  23.  
  24. for f in $scriptlist; do
  25.     head -1 $f | sed -e 's/^\#\![     ]*//' | cut -d" " -f1
  26. done | sort -u
  27.  
  28. for f in $liblist $exelist ; do
  29.     objdump -p $f | awk '
  30.     BEGIN { START=0; LIBNAME=""; }
  31.     /Version References:/ { START=1; }
  32.     /required from/ && (START==1) {
  33.         sub(/:/, "", $3);
  34.         LIBNAME=$3;
  35.     }
  36.     (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) { print LIBNAME "(" $4 ")"; }
  37.     /^$/ { START=0; }
  38.     '
  39. done | sort -u
  40.